package com.smart.daotest;

import com.smart.dao.RecorderDao;
import com.smart.domain.Recorder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTransactionalTestNGSpringContextTests;
import org.testng.annotations.Test;

import java.util.Date;

@ContextConfiguration("classpath*:/Room-context.xml")

@Rollback(false)

public class Testrecorder extends AbstractTransactionalTestNGSpringContextTests {

    @Autowired
    private RecorderDao recorderDao;


    @Test
    public void testdaorecorder() {
        Recorder cp = new Recorder();

        cp.setRecorder_courseName("英语");
        cp.setRecorder_teacherName("王磊");
        cp.setRecorder_computerRoom("机房二");
        cp.setRecorder_lesson("zuoye ");
        cp.setRecorder_classes("计科161");
        cp.setRecorder_week(13);
        cp.setRecorder_weekNumber(10);
        Date date1 = new Date(118,6,7,10,30);
        Date date2 = new Date(118,6,7,12,10);
        cp.setRecorder_startTime(date1);
        cp.setRecorder_stopTime(date2);
        recorderDao.addRecorder(cp);

    }

    @Test
    public void testdaoupdaterecorder(){
        Recorder recorder2 =new Recorder();
        recorder2.setRecorder_week(14);
        recorder2.setRecorder_weekNumber(10);
        int a= recorderDao.updateRecorder(recorder2);
        if(a>0){
            System.out.print("修改成功");
        }
        else{
            System.out.print("修改失败");
        }
    }


    @Test
    public void testdeleterecorder(){
        Recorder recorder3 = new Recorder();
        recorder3.setRecorder_lesson("zuoye");
        int a=recorderDao.deleteRecorder(recorder3);
        System.out.println(a);
    }

    @Test
    public  void testqueryrecorder(){
        Recorder com =new Recorder();
        com.setRecorder_computerRoom("机房二");
        recorderDao.queryRecorder(com);
    }
    @Test
    public  void testqueryrecorderlist(){
        Recorder com= new Recorder();
        recorderDao.querylistRecorder(com);
    }

}
